Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(github): add github integration #368

Merged
merged 1 commit into from
Dec 14, 2024

Conversation

ReenigneArcher
Copy link
Member

@ReenigneArcher ReenigneArcher commented Nov 9, 2024

Description

This PR aims to more tightly integrate GitHub with our discord bot.

Main features to add

  1. Assign roles based on GitHub sponsorship status
  2. Assign dev-user role based on GitHub account... (whether it exists, has contributed, or something along those lines)

Many drive by fixes in this PR:

  • added a common colors dictionary for discord embed colors
  • added unit tests for discord bot tasks
  • added cryptography sub module for handling self signed certs used by Flask
  • added database sub module for handling shelve database
  • discord embeds now use correct timestamp property
  • fixed some over indented code (return early where possible)
  • much improved test coverage
  • run unit test discord bot threaded instead of in a custom async loop (loop was hanging)

TODO:

  • Persist OAuth status?
  • Periodically check GitHub user's for sponsor status, and add user to sponsor roles, or revoke accordingly
  • Callback to public URL
  • Possible to hide disocrd bot IP? Unlikely, I guess
  • Improved SSL certs
  • Update dockerfile
  • Update readme/docs
  • Add/update unit tests
    • Unit tests hang on unix due to async nonsense
    • Unit tests do not post comment even though tests pass (on Windows)
    • More test coverage
  • Add GitHub username to user_info_commmand
  • Add alternate authentication via GitHub directly instead of only Discord
  • Update the ephemeral command once the authorization flow has finished, errored, or timed out
  • Assign dev-user (github-user) role automatically
  • Do not remove roles unless assigned by our bot (in case GitHub user is a Patreon)

Screenshot

Issues Fixed or Closed

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

Copy link

codecov bot commented Nov 9, 2024

Codecov Report

Attention: Patch coverage is 81.47368% with 88 lines in your changes missing coverage. Please review.

Project coverage is 67.58%. Comparing base (830ca7b) to head (aacbcb6).

Files with missing lines Patch % Lines
src/discord/cogs/github_commands.py 39.53% 26 Missing ⚠️
src/discord/cogs/moderator_commands.py 4.16% 23 Missing ⚠️
src/discord/tasks.py 88.37% 15 Missing ⚠️
src/__main__.py 0.00% 12 Missing ⚠️
src/common/webapp.py 96.66% 4 Missing ⚠️
src/discord/views.py 25.00% 3 Missing ⚠️
src/common/common.py 85.71% 1 Missing ⚠️
src/discord/bot.py 97.95% 1 Missing ⚠️
src/discord/cogs/base_commands.py 50.00% 1 Missing ⚠️
src/discord/cogs/fun_commands.py 50.00% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #368       +/-   ##
===========================================
+ Coverage   46.81%   67.58%   +20.76%     
===========================================
  Files          15       21        +6     
  Lines         786     1092      +306     
===========================================
+ Hits          368      738      +370     
+ Misses        418      354       -64     
Files with missing lines Coverage Δ
src/common/crypto.py 100.00% <100.00%> (ø)
src/common/database.py 100.00% <100.00%> (ø)
src/common/globals.py 100.00% <100.00%> (ø)
src/common/sponsors.py 100.00% <100.00%> (ø)
src/common/time.py 100.00% <100.00%> (ø)
src/reddit/bot.py 80.26% <100.00%> (+<0.01%) ⬆️
src/common/common.py 92.85% <85.71%> (ø)
src/discord/bot.py 92.39% <97.95%> (+23.16%) ⬆️
src/discord/cogs/base_commands.py 32.00% <50.00%> (ø)
src/discord/cogs/fun_commands.py 42.10% <50.00%> (ø)
... and 7 more

... and 1 file with indirect coverage changes

@ReenigneArcher ReenigneArcher force-pushed the feat/github/add-github-integration branch 2 times, most recently from 14cb7f9 to 69a160c Compare November 10, 2024 05:37
@ReenigneArcher ReenigneArcher force-pushed the feat/github/add-github-integration branch 4 times, most recently from d539168 to 0480459 Compare November 19, 2024 04:43
src/reddit/bot.py Outdated Show resolved Hide resolved
@ReenigneArcher ReenigneArcher force-pushed the feat/github/add-github-integration branch 22 times, most recently from 7bdfdcf to 04e118e Compare November 23, 2024 19:00
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@ReenigneArcher ReenigneArcher force-pushed the feat/github/add-github-integration branch 7 times, most recently from d77bb86 to f563b2d Compare December 4, 2024 02:51
@ReenigneArcher ReenigneArcher marked this pull request as ready for review December 4, 2024 02:53
@ReenigneArcher ReenigneArcher force-pushed the feat/github/add-github-integration branch 12 times, most recently from d04be91 to 8c7b8ea Compare December 8, 2024 23:20
@ReenigneArcher ReenigneArcher force-pushed the feat/github/add-github-integration branch 2 times, most recently from 5e3882c to 45741aa Compare December 14, 2024 16:49
@ReenigneArcher ReenigneArcher force-pushed the feat/github/add-github-integration branch from 45741aa to aacbcb6 Compare December 14, 2024 17:18
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
2 New issues
7 Security Hotspots
2 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 36 out of 36 changed files in this pull request and generated no comments.

@ReenigneArcher ReenigneArcher merged commit 630e2c5 into master Dec 14, 2024
13 of 14 checks passed
@ReenigneArcher ReenigneArcher deleted the feat/github/add-github-integration branch December 14, 2024 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Receive and process external webhooks
1 participant